import request from '@/utils/request'

// 获取路由 (兼容老接口)
export const getRouters = () => {
  return request({
    url: '/getRouters',
    method: 'get'
  })
}

// 获取目录树
export const fetchTree = () => {
  return request({
    url: '/system/menu/tree',
    method: 'get'
  })
}

// 获取目录树(指定角色id)
export const fetchRoleMenu = (data) => {
  return request({
    url: '/system/menu/tree/role',
    method: 'get',
    params: data
  })
}

// 指定角色授权目录树
export function grant(data) {
  return request({
    url: '/system/menu/grant',
    method: 'post',
    data: data
  })
}

// 新增
export function add(data) {
  return request({
    url: '/system/menu',
    method: 'post',
    data: data
  })
}

// 修改
export function update(data) {
  return request({
    url: '/system/menu',
    method: 'patch',
    data: data
  })
}

// 删除
export function deleteData(ids) {
  return request({
    url: '/system/menu',
    method: 'delete',
    data: ids
  })
}
